import wepy from 'wepy'

export default class baseMixin extends wepy.mixin {
  data = {
    isLoading:false,
    pages:[],
    currentUser:{},//当前用户
    mixin: 'This is base mixin data.'
  }

  computed = {
    now () {
      return +new Date()
    }
  }
  methods = {
    tap () {
      this.mixin = 'base mixin data was changed'
      console.log('base mixin method tap')
    },
    makePhoneCall(phone){
      console.log("phone",phone);
      if(phone!=''){
        wx.makePhoneCall({
          phoneNumber: phone,
          success:function(){
            console.log("拨打电话成功！")
          },
          fail:function(){
            console.log("拨打电话失败！")
          }})
      }else{
        Tips.alert("暂无电话");
      }
    }
  }

  getCurrentUser(){
    this.currentUser = wepy.getStorageSync("user");
    console.log("baseMixin 获取当前用户",this.currentUser)

  }

  onShow() {
    this.pages = getCurrentPages();
    console.log('base mixin onShow this.pages',this.pages)
  }

  onLoad() {
    console.log('base mixin onLoad')
    this.getCurrentUser();
  }
}
